# docker image build -t kkb:0.0.1 .
From centos:7

ARG proPath="/kkb"
ARG softPath="/kkb/soft"
ARG installPath="/kkb/install"
ARG JAVA_HOME=$installPath"/jdk1.8.0_141"
ARG HADOOP_HOME=$installPath"/hadoop-3.1.4"
ARG ZK_HOME=$installPath"/apache-zookeeper-3.6.2-bin"
ARG SPARK_HOME=$installPath"/spark-3.0.0-bin-hadoop3.2"
ARG USER_HOME="/home/hadoop"

COPY ./lib/Centos-7.repo  /tmp/Centos-7.repo
COPY ./lib/apache-zookeeper-3.6.2-bin.tar.gz /tmp/apache-zookeeper-3.6.2-bin.tar.gz
COPY ./lib/hadoop-3.1.4.tar.gz /tmp/hadoop-3.1.4.tar.gz
COPY ./lib/jdk-8u141-linux-x64.tar.gz /tmp/jdk-8u141-linux-x64.tar.gz
COPY ./lib/spark-3.0.0-bin-hadoop3.2.tgz /tmp/spark-3.0.0-bin-hadoop3.2.tgz
COPY ./lib/authBatchSSH.sh /tmp/authBatchSSH.sh
COPY ./lib/node1Conf.sh /tmp/node1Conf.sh
COPY ./lib/xcall.sh /tmp/xcall.sh

RUN mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup \
    && mv /tmp/Centos-7.repo /etc/yum.repos.d/CentOS-Base.repo \
    && sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo \
    && yum makecache \
    && yum -y install ntpdate expect cronie sudo rsync openssh-clients openssh-server  openssl-devel net-tools \
    && adduser hadoop  \
    && echo 'hadoop:123456' | chpasswd \
    && echo "hadoop ALL=(ALL)    ALL" >>  /etc/sudoers \
    && mkdir -p $softPath  \
    && mkdir -p $installPath  \
    && mkdir -p $USER_HOME/bin  \
    && mv /tmp/jdk-8u141-linux-x64.tar.gz $softPath/jdk-8u141-linux-x64.tar.gz \
    && mv /tmp/hadoop-3.1.4.tar.gz $softPath/hadoop-3.1.4.tar.gz \
    && mv /tmp/apache-zookeeper-3.6.2-bin.tar.gz $softPath/apache-zookeeper-3.6.2-bin.tar.gz \
    && mv /tmp/spark-3.0.0-bin-hadoop3.2.tgz $softPath/spark-3.0.0-bin-hadoop3.2.tgz \
    && tar -zxf $softPath/jdk-8u141-linux-x64.tar.gz -C $installPath \
    && tar -zxf $softPath/hadoop-3.1.4.tar.gz -C $installPath \
    && tar -zxf $softPath/apache-zookeeper-3.6.2-bin.tar.gz -C $installPath \
    && tar -zxf $softPath/spark-3.0.0-bin-hadoop3.2.tgz -C $installPath \
    && mv /tmp/authBatchSSH.sh   $USER_HOME/bin/authBatchSSH.sh \
    && mv /tmp/node1Conf.sh   $USER_HOME/bin/node1Conf.sh \
    && mv /tmp/xcall.sh   $USER_HOME/bin/xcall.sh \
    && chown -R hadoop:hadoop $proPath \
    && chown -R hadoop:hadoop $USER_HOME/bin \
    && ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key \
    && ssh-keygen -t ecdsa -b 256 -f /etc/ssh/ssh_host_ecdsa_key \
    && ssh-keygen -t ed25519 -b 256 -f /etc/ssh/ssh_host_ed25519_key \
    && echo 'root:123456' |chpasswd \
    && sed -ri 's/^PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config \
    && sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config \
    && echo "su - hadoop" >> /root/.bashrc \
    && echo "export JAVA_HOME="$JAVA_HOME >> /home/hadoop/.bashrc \
    && echo "export HADOOP_HOME="$HADOOP_HOME >> /home/hadoop/.bashrc \
    && echo "export ZK_HOME="$ZK_HOME >> /home/hadoop/.bashrc \
    && echo "export PATH=$PATH:"$JAVA_HOME"/bin:"$HADOOP_HOME"/bin:"$HADOOP_HOME"/sbin:"$ZK_HOME"/bin" >> /home/hadoop/.bashrc 
    


ENV JAVA_HOME $JAVA_HOME
ENV HADOOP_HOME $HADOOP_HOME
ENV ZK_HOME $ZK_HOME
ENV PATH $PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$ZK_HOME/bin

#USER hadoop
WORKDIR /home
CMD  ["/usr/sbin/sshd", "-D"]
